function PromsieAll(promises) {
    let res = []
    let count = 0
    let len = promises.length
    return new Promise((resolve, reject) => {
        promises.map((item, index) => {
            Promise.resolve(item).then(value => {
                res[index] = value
                count++
                if (count === len) {
                    resolve(res)
                }
            }).catch(err => {
                reject(err)
            })
        })
    })
}

const p1 = Promise.resolve('123')
const p2 = Promise.resolve('456')
const p3 = Promise.resolve('789')
// const p4 = Promise.reject('err')
const p5 = new Promise((resolve, reject) => {
    resolve('p5')
})
// console.log(p1)
// console.log(p2)
// console.log(p3)
PromsieAll([p1, p2, p3]).then(res => {
    console.log(res)
}, err => {
    console.log(err)
})
PromsieAll([p1, p2, p5]).then(res => {
    console.log(res)
}, err => {
    console.log(err)
})
// PromsieAll([p1, p4, p3])